﻿/*
 *Copyright(C) 2024 by CometGamming All rights reserved.
 *Unity版本：2022.3.43f1c1 
 *作者:程一峰  
 *创建日期: 2024-10-22 
 *模块说明：简易状态机
 *版本: 0.1.0
*/

using Sirenix.OdinInspector;
using UnityEngine;
using Warfare.FSM;

namespace GameAIStudy
{
    /// <summary>
    /// 测试用行为处理；
    /// </summary>
    public class SamplePlayer : MonoBehaviour, I_FSMActor
    {
        public string Name => gameObject.name;

        public float GetTime => Time.realtimeSinceStartup;


        public void SetTargetPosition(Vector3 pos) => Target = pos;

        [DisplayAsString, LabelText("目标位置")]
        public Vector3 Target;

        [LabelText("速度")]
        public float Speed = 2;

        private void Update()
        {
            if (Target == transform.position)
                return;

            var fwd = (Target - transform.position).normalized;
            var delta = fwd * Speed * Time.deltaTime;
            transform.position += delta;
        }

    }
}
